<?php

namespace app\api\controller;

use app\common\controller\Api;
use app\common\model\MoneyLog as ModelMoneyLog;

/**
 * 余额变动
 */
class MoneyLog extends Api
{
    protected $noNeedLogin = [];
    protected $noNeedRight = ['*'];

    /**
     * 首页
     *
     */
    public function index()
    {
        $page = (int)$this->request->request('page');
        $page = empty($page) ? 0 : ($page - 1) * 10;
        
        $model = new ModelMoneyLog();
        $data['rows'] = $model->where('user_id',$this->auth->id)->limit($page,10)->select();
        $data['today'] = $model->where('user_id',$this->auth->id)->whereTime('createtime','today')->sum('money');
        $data['money'] = $this->auth->money * 1;

        $this->success('请求成功',$data);
    }
    
}
